/**
 * Copyright(c) 2025 hbswxx.com, All Rights Reserved. Author: kouqiang Create date: 2025/5/29
 */
package cn.sw.syncdata.local.mapper;

import cn.sw.syncdata.entity.HeartInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.executor.BatchResult;

import java.util.List;

/**
 * description: 本地header库
 *
 * @author kouqiang
 * @date 2025/5/29 13:30
 */
public interface ILocalDataBaseHeaderMapper extends BaseMapper<HeartInfo> {
    /**
     * description: 数据入库
     *
     * @param heartInfos
     * @author kouqiang
     * @date 2025/5/29 13:31
     * @return: long
     */





    @Insert("<script>" +
            "insert into heartinfo_tab (community_indexcode, log_level, log_info, addtime) " +
            "values " +
            "<foreach collection=\"list\" item=\"item\" separator=\",\">" +
            "(#{item.communityIndexcode}, #{item.logLevel}, #{item.logInfo}, #{item.addtime})" +
            "</foreach>" +
            "</script>")
    long insertDatas(List<HeartInfo> heartInfos);

//    default long insertDatas(List<HeartInfo> heartInfos) {
//        List<BatchResult> result = insert(heartInfos);
//        int total = result.stream().mapToInt(br -> br.getUpdateCounts().length).sum();
//        return total;
//    }
}
